package com.tyl.thread01;

// 通过婚庆公司代理结婚
// 真是对象跟代理对象都要实现同一个接口
public class Proxy {
    public static void main(String[] args) {
        Wedding wedding=new Wedding(new You());
        wedding.happyMarry();
    }
}
interface Marry{
    //结婚
    void happyMarry();
}

class You implements Marry{

    @Override
    public void happyMarry() {
        System.out.println("tyl结婚了，很开心！");
    }
}

class Wedding implements Marry{
    private Marry Target;

    public Wedding(Marry target) {
        Target = target;
    }
    @Override
    public void happyMarry() {

        before();
        this.Target.happyMarry();//目标结婚
        later();
    }

    private void later() {
        System.out.println("结婚之后收尾款");
    }

    private void before() {
        System.out.println("结婚之前布置现场");
    }


}
